import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import Icons from 'unplugin-icons/vite'
import IconResolver from 'unplugin-icons/resolver'
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true },
  vite: {
    plugins: [
      Components({
        resolvers: [
          AntDesignVueResolver({
            importStyle: false, // css in js
          }),
          IconResolver({
            // 设置图标前缀
            prefix: 'i',
            enabledCollections: ['ep', 'ant-design'],
          }),
        ],
      }),
      Icons({
        // 自动注册安装
        autoInstall: true,
      }),
    ],
    ssr: {
      // 不打包 ant-design-vue
      noExternal: ['ant-design-vue'],
    },
    // 配置代理
    /* server: {
      proxy: {
        '/api': {
          target: 'https://api.nuxt.com', // 目标服务器地址
          changeOrigin: true, // 允许跨域
          rewrite: (path) => path.replace(/^\/api/, ''), // 重写路径
        },
      },
    }, */
  },
  modules: ['@pinia/nuxt', 'pinia-plugin-persistedstate/nuxt', '@prisma/nuxt'],
  experimental: {
    componentIslands: true,
  },
  // 动态配置
  runtimeConfig: {
    SecretKey: process.env.Secret_Key,
    SecretId: process.env.Secret_Id,
  },
})
